#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int n, h1, m1, s1, h2, m2, s2, cnt;
    scanf("%lld:%lld:%lld", &h1, &m1, &s1);
    scanf("%lld:%lld:%lld", &h2, &m2, &s2);
    cin >> n;
    s1 += m1 * 60 + h1 * 3600;
    s2 += m2 * 60 + h2 * 3600;
    cnt = (s2 - s1) * n;
    cout << cnt;
    return 0;
}